<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" name="" id="">
    <script>
        document.addEventListener('keydown', function(e){
            // console.log(e);
            console.log(e.keyCode); // 相应键的ascii码值
            // 1. keyup 和keydown 事件不区分字母大小写aA都是65
            // 2. keypress 区分大小写
        })

        // 按键按下 s  搜索框获得焦点  
        var search = document.querySelector('input');
        document.addEventListener('keyup', function(e) {
            if (e.keyCode == 83 ) {
                search.focus()
            }
        })
    </script>
</body>
</html>